package gameclasses;

import datastructures.Vector2f;
import interfaces.IUnit;

import exceptions.Exception;

public class Tank extends IUnit {

	public static final int M1Abrams = 1;
	
	public static Tank generateTemplateTank(GameManager gm, int playerID, Vector2f spawn, int template)
	{
		switch (template)
		{
		case M1Abrams: 
		default: return new Tank(gm, playerID, spawn, 1000, 500, 1000, 3, 5, 20, 1.3, 40);
		}
	}
	
	private Tank(GameManager gm, int playerID, Vector2f position, int hitPoints, int attackPoints, int price, 
			double speed, double shootrange, double maxFuelAmount, double FuelUsage, int maxAmmo) {
		super(gm,playerID,position,hitPoints,attackPoints,price,speed,shootrange,maxFuelAmount,FuelUsage,maxAmmo,IUnit.TYPE_LAND);
	}

	@Override
	public int move(Vector2f p) 
	{
		if (!map.isInMap(p))
		{
			return Exception.DESTINATION_OUT_OF_MAP;
		}
		if (!map.isPassable(IUnit.TYPE_LAND, p))
		{
			return Exception.TERRAIN_NOT_PASSABLE;
		}
		double d = map.getDistanceBetweenPoints(this.position,p);
		if(d > speed)
		{
			return Exception.DESTINATION_TOO_FAR;
		}
		if(currentFuel<(d*fuelUsage))
		{
			return Exception.OUT_OF_FUEL;
		}
		currentFuel -= (d*fuelUsage);
		position = p;
		return Exception.MOVING;
		
	}

	@Override
	public void stopMoving() {
	}

	@Override
	public void continueMoving() {
	}


	
}

